package com.googlecode.lookie.platform.laf;

import java.util.List;

import org.springframework.beans.factory.InitializingBean;

import com.googlecode.lookie.swing.laf.DefaultLookAndFeelDescriptor;
import com.googlecode.lookie.swing.laf.LookAndFeelRegistry;

public class LookAndFeelDescriptorGroup
    implements InitializingBean
{

    private LookAndFeelRegistry registry;

    private String groupId;

    private List<DefaultLookAndFeelDescriptor> descriptors;

    public void setRegistry( LookAndFeelRegistry registry )
    {
        this.registry = registry;
    }

    public void setGroupId( String groupId )
    {
        this.groupId = groupId;
    }

    public void setDescriptors( List<DefaultLookAndFeelDescriptor> descriptors )
    {
        this.descriptors = descriptors;
    }

    public void afterPropertiesSet()
        throws Exception
    {
        for ( DefaultLookAndFeelDescriptor descriptor : descriptors )
        {
            descriptor.setId( groupId + "." + descriptor.getName() );
            descriptor.setGroupId( groupId );
            //            descriptor.setTreeCellRendererClassName( "org.jvnet.substance.api.renderers.SubstanceDefaultTreeCellRenderer" );
            registry.addDescriptor( descriptor );
        }
    }

}
